package com.gzck.gzck_verson2.controller;


import com.gzck.gzck_verson2.pojo.GSensorOriginalRelation;
import com.gzck.gzck_verson2.service.IGSensorOriginalRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 传感器（采集仪）原始数据表 前端控制器
 * </p>
 *
 * @author 任永辉
 * @since 2024-01-27
 */
@RestController
@RequestMapping("/g-sensor-original-relation")
public class GSensorOriginalRelationController {

    @Autowired
    private IGSensorOriginalRelationService sensorOriginalRelationService;

    // 添加传感器和原始数据关系
    @PostMapping("/add")
    public boolean addSensorOriginalRelation(@RequestBody GSensorOriginalRelation sensorOriginalRelation) {
        return sensorOriginalRelationService.save(sensorOriginalRelation);
    }

    // 删除传感器和原始数据关系
    @DeleteMapping("/delete/{id}")
    public boolean deleteSensorOriginalRelation(@PathVariable Long id) {
        return sensorOriginalRelationService.removeById(id);
    }

    // 更新传感器和原始数据关系
    @PutMapping("/update")
    public boolean updateSensorOriginalRelation(@RequestBody GSensorOriginalRelation sensorOriginalRelation) {
        return sensorOriginalRelationService.updateById(sensorOriginalRelation);
    }

    // 查询单个传感器和原始数据关系
    @GetMapping("/{id}")
    public GSensorOriginalRelation getSensorOriginalRelation(@PathVariable Long id) {
        return sensorOriginalRelationService.getById(id);
    }

    // 查询所有传感器和原始数据关系
    @GetMapping("/all")
    public List<GSensorOriginalRelation> getAllSensorOriginalRelations() {
        return sensorOriginalRelationService.list();
    }
}
